<html>

<!-- $Id: mdi-tab.html 246 2008-01-21 20:40:10Z diegoiast $ -->

<head>
	<title>qtmdi library - Mdi TabWidget</title>
</head>

<body>
<h1 style=" display: block; background-color: rgb(166,206,57); ">Target</h1>
<p>
	This application demostrates how to assign different menus for different widgets.
	The menus and toolbars of the widgets inside the tab widget (<code>qmdiClient</code>) will be
	merged into the main application window toolbars and menus.
	<br>
	There are 3 sets of widgets on this app:
	<ol>
		<li> The start page - without menus nor toolbars (no menu to add it, don't close it)
		<li> Text editor - text manipulating menus and toolbars
		<li> Help browse - with browser related menus and toolbars
	</ol>
	Please note, that it is OK to delete mdi clients from the main application, from the tab widget
	and also from the client themsevles using <code>deleteLater()</code>.
</p>

<p>
	You have also the option for recompile this application so that every mdi client
	will use a <b>single toobar</b>. Sometimes making several toolbars can look wierd to the user
	and it will be better from usability point of view to have a single toolbar. See the code for more details.
</p>

<h1 style=" display: block; background-color: rgb(166,206,57); ">The code</h1>
<p>
	The code in the clients does not have to worry about how and when the toolbars and menus will be merged.
	One just inherits the main window from <code>qmdiHost</code>, the clients from <code>qmdiClient</code>
	and the new widgets must be inserted into <code>qmdiTab</code>.<br>
	If a widget which does not inherit <code>qmdiClient</code> will be displayed on the tab widget, no menus and toolbars
	will be merged into the main window menus and toolbars.
</p>

<p> This code is taken from the help browser. You only have to define actions, and connect them. Nothing more.</p>
<pre style="width: 70%; display: block; margin-left: 15%; margin-right: 15%; border:1px solid gray; background-color: silver; font-family: monospace;">
QexHelpBrowser::QexHelpBrowser( QUrl home, QWidget *parent )
	:QTextBrowser(parent)
{
	actionBack	= new QAction( QIcon(":images/prev.png"), tr("&amp;Back"), this );
	actionNext	= new QAction( QIcon(":images/next.png"), tr("&amp;Next"), this );
	actionHome	= new QAction( QIcon(":images/home.png"), tr("&amp;Home"), this );
	actionCopy	= new QAction( QIcon(":images/copy.png"), tr("&amp;Copy"), this  );
	actionZoomIn	= new QAction( QIcon(":images/zoomin.png"), tr("&amp;Zoom in"), this  );
	actionZoomOut	= new QAction( QIcon(":images/zoomout.png"), tr("&amp;Zoom out"), this  );

	connect( this, SIGNAL(backwardAvailable(bool)), actionBack, SLOT(setEnabled(bool)) );
	connect( this, SIGNAL(forwardAvailable(bool)), actionNext, SLOT(setEnabled(bool)) );
	connect( this, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)) );
	connect( actionBack, SIGNAL(triggered()), this, SLOT(backward()));
	connect( actionNext, SIGNAL(triggered()), this, SLOT(forward()));
	connect( actionHome, SIGNAL(triggered()), this, SLOT(goHome()));
	connect( actionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn()));
	connect( actionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut()));

	actionCopy->setEnabled(false);
	actionNext->setShortcut( QKeySequence("Alt+Right") );
	actionBack->setShortcut( QKeySequence("Alt+Left") );
	actionHome->setShortcut( QKeySequence("Alt+Home") );
	actionZoomIn->setShortcut( QKeySequence("Ctrl++") );
	actionZoomOut->setShortcut( QKeySequence("Ctrl+-") );

	// define the menus for this widget
	menus["&amp;Edit"]->addAction( actionCopy );
	
	menus["&amp;Navigation"]->addAction( actionHome );
	menus["&amp;Navigation"]->addAction( actionBack );
	menus["&amp;Navigation"]->addAction( actionNext );
	menus["&amp;Navigation"]->addSeparator();
	menus["&amp;Navigation"]->addAction( actionZoomIn );
	menus["&amp;Navigation"]->addAction( actionZoomOut );

	// define the toolbars for this widget
	toolbars["Edit operations"]->addAction( actionCopy );
	toolbars["Navigation"]->addAction( actionHome );
	toolbars["Navigation"]->addAction( actionBack );
	toolbars["Navigation"]->addAction( actionNext );
	toolbars["Navigation"]->addSeparator();
	toolbars["Navigation"]->addAction( actionZoomIn );
	toolbars["Navigation"]->addAction( actionZoomOut );
	
	homePage = home;
	setSource( homePage );
}
</pre>


</body>

</html>
